function deepCopy(target) {
    let result = null
    if (typeof target === 'object') {
        result = target instanceof Array ? [] : {}
    }
    for (i in target) {
        if (target.hasOwnProperty(i)) {
            if (typeof target[i] === 'object') {
                result[i] = deepCopy(target[i])
            } else {
                result[i] = target[i]
            }
        }
    }
    return result
}

// let arr = [1, { A: 1 }]
// let arr1 = deepCopy(arr)
// arr[1].A = 2
// console.log(arr1)


let obj = {
    A: 1,
    B: {
        AA: 1
    },
    say() {
        console.log(1)
    }
}
let obj1 = deepCopy(obj)
obj.B.AA = 2
console.log(arr1)